package com.javaear.zblog4java.desktop;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.javaear.generalmapper.GeneralMapper;
import com.javaear.zblog4java.system.entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class IndexView {

    @Autowired
    private GeneralMapper generalMapper;

    @RequestMapping("index")
    public String index(ModelMap modelMap) {
        modelMap.put("blog-title","测试博客标题");
        modelMap.put("blog-sub-title","测试博客子标题");
        modelMap.put("categorys",generalMapper.selectList(new EntityWrapper<>(new CategoryModel())));
        int pageNo=1;
        int pageSize=10;
        Page<ArticleModel> page=new Page<>(pageNo,pageSize);
        List<ArticleModel> articleModelList=generalMapper.selectPage(page,new EntityWrapper<>(new ArticleModel()));
        System.out.println("总页数:"+page.getTotal());
        modelMap.put("articles",articleModelList);
        return "desktop/default/index";
    }
}
